package com.manage.platform.controller;

import com.manage.platform.dto.AchieveApprovalDto;
import com.manage.platform.dto.FirstPageAchieveDto;
import com.manage.platform.dto.query.AchievePageQuery;
import com.manage.platform.dto.query.NewCenterQuery;
import com.manage.platform.service.impl.*;
import com.manage.platform.utils.R;
import com.manage.platform.utils.RPage;
import com.manage.platform.vo.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * YWD
 * 2025/9/22
 */
@AllArgsConstructor
@RestController
@RequestMapping("/firstPage")
@Tag(name = "首页")
public class FirstPageController {

    private final NewCenterServiceImpl newCenterServiceImpl;
    private final AchieveServiceImpl achieveServiceImpl;
    private final IndicatorSystemImpl indicatorSystemImpl;
    private final TaskServiceImpl taskServiceImpl;
    private final OrganizeServiceImpl organizeServiceImpl;

    //资讯中心列表
    @PostMapping("/getNewCenterPage")
    @Operation(summary = "1.查询新闻列表(分页)")
    public R<RPage<List<NewCenterVo>>> getNewCenterPage(@RequestBody NewCenterQuery query) {
        return R.ok(newCenterServiceImpl.getNewCenterPage(query));
    }

    @GetMapping("/getNewCenterDetails/{id}")
    @Operation(summary = "2.查询新闻详情")
    public R<NewCenterVo> getNewCenterDetails(@Schema(description = "新闻ID") @PathVariable("id") Long id) {
        return R.ok(newCenterServiceImpl.getNewCenterDetails(id));
    }

    //热门文章列表
    @GetMapping("/getNewTopList")
    @Operation(summary = "3.热门文章列表")
    public R<List<NewCenterVo>> getNewTopList(@Schema(description = "新闻类型(EDUCATION=教育新闻, MEDIA=媒体报道)") @RequestParam String type) {
        return R.ok(newCenterServiceImpl.getNewTopList(type,1));
    }
    //最新文章列表
    @GetMapping("/getNewTopOneList")
    @Operation(summary = "4.最新文章列表")
    public R<List<NewCenterVo>> getNewTopOneList(@Schema(description = "新闻类型(EDUCATION=教育新闻, MEDIA=媒体报道)") @RequestParam String type) {
        return R.ok(newCenterServiceImpl.getNewTopList(type,2));
    }

    @GetMapping("/getNewTopDetails/{id}")
    @Operation(summary = "5.文章详情")
    public R<NewCenterVo> getNewTopDetails(@Schema(description = "热门文章ID") @PathVariable("id") Long id) {
        return R.ok(newCenterServiceImpl.getNewCenterDetails(id));
    }


    //审批中心列表======================================================================================================
    @PostMapping("/getAchievePage")
    @Operation(summary = "6.查询成果审批列表(分页)")
    public R<RPage<List<AchieveVo>>> getAchievePage(@RequestBody AchievePageQuery query) {
        return R.ok(achieveServiceImpl.getAchievePage(query));
    }

    @GetMapping("/getAchieveDetails/{id}")
    @Operation(summary = "7.查询成果审批详情")
    public R<AchieveDetailsVo> getAchieveDetails(@Schema(description = "成果审批ID") @PathVariable("id") Long id) {
        return R.ok(achieveServiceImpl.getAchieveDetails(id));
    }

    @PutMapping("/approvalAchieve")
    @Operation(summary = "8.成果审批")
    public R<Boolean> approvalAchieve(@RequestBody AchieveApprovalDto dto) {
        return R.ok(achieveServiceImpl.approvalAchieve(dto));
    }


    @PostMapping("/getAchieveHistoryList")
    @Operation(summary = "9.成果审批历史参考")
    public R<List<AchievePartVo>> getAchieveHistoryList(@RequestBody FirstPageAchieveDto dto) {
        return R.ok(achieveServiceImpl.getAchieveHistoryList(dto));
    }

    //筛选项===========================================================================================================
    //================================================================================================================
    @GetMapping("/getIndicatorList")
    @Operation(summary = "指标体系列表(筛选项)")
    public R<List<CommonVo>> getIndicatorList(@Schema(description = "指标体系名称") @RequestParam(value = "name", required = false) String name) {
        return R.ok(indicatorSystemImpl.getIndicatorList(name));
    }

    @GetMapping("/getTaskList")
    @Operation(summary = "任务列表(筛选项)")
    public R<List<CommonVo>> getTaskList(@Schema(description = "任务名称") @RequestParam(value = "name", required = false) String name) {
        return R.ok(taskServiceImpl.getTaskList(name));
    }

    @GetMapping("/getDepartmentList")
    @Operation(summary = "部门列表(筛选项)")
    public R<List<CommonVo>> getDepartmentList(@Schema(description = "部门名称")
                                               @RequestParam(value = "name", required = false) String name) {
        return R.ok(organizeServiceImpl.getDepartmentList(name));
    }

}
